#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;


int n;
int nx, ny;
struct point
{
    long long x;
    long long  y;
    long long num;
};

bool cmp(const point &a, const point &b)
{
    if (a.x < b.x)
        return true;
    else if (a.x == b.x)
        {
            if (a.y < b.y)
                return true;
            else
                return false;
        }
    else
        return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    point a[n+10];
    for (int i = 1; i <= n; i++)
    {
        cin >> nx >> ny;
        a[i].x = nx;
        a[i].y = ny;
        a[i].num = i;
    }
    sort(a + 1, a + 1 + n, cmp);
    for (int i = 1; i <= n; i++)
    {
        cout<<a[i].x<<" "<<a[i].y<<endl;
    }
    for (int i = 1; i < n; i++)
    {
       cout<<a[i].num<<" ";
    }
    cout<<a[n].num<<endl;
   // system("pause");
    return 0;
}
